import {computed} from 'vue'
import { useStore} from "vuex"
export function useMapper(mapper, mapFn) {
  // 获取到store对象
  const store = useStore()
  // 获取对应的对象function：{name:function,age:function}
  const storeStateFns = mapFn(mapper)

  // storeState
  const storeState = {}

  Object.keys(storeStateFns).forEach( fnKey => {
    const fn = storeStateFns[fnKey].bind({$store:store})
    storeState[fnKey] = computed(fn)
  })
  return storeState
}